package com.syedu.day06.homework;

/**
 * description：电脑类
 * @author Administrator
 * @date 2022/3/15 15:18
 */
public class Computer {
    /**属性*/
    String brand;
    double price;
    String description;
    Screen screen;

    public Computer() {

    }

    public Computer(String _brand, double _price, String _description) {
        brand = _brand;
        //判断
        if (_price < 1000 || _price > 20000) {
            System.err.println("价格不合法...");
            price = 2000;
        } else {
            price = _price;
        }
        description = _description;
    }

    public Computer(String _brand, double _price, String _description, Screen _screen) {
        brand = _brand;
        //判断
        if (_price < 1000 || _price > 20000) {
            System.err.println("价格不合法...");
            price = 2000;
        } else {
            price = _price;
        }
        description = _description;
        screen = _screen;
    }

    /**
     * 打印电脑信息的方法
     */
    public void printInfo() {
        String info = "电脑品牌: " + brand + ", 价格: " + price + ",描述: " + description;
        //判断电脑是否有屏幕信息
        if (screen != null) {
            info += "\n\t显示器类型: " + screen.type + ",显示器尺寸: " + screen.size + ",显示器品牌: " + screen.brand;
        }else{
            info += "\n\t暂无屏幕信息...";
        }
        System.out.println(info);
    }
}